//
//  Tree.cpp
//  Node
//
//  Created by zhangjikuan on 2020/12/14.
//  Copyright © 2020 hsgd. All rights reserved.
//

#include "Tree.hpp"


bool TreeNodeAlgorithm::check(TreeNode *p, TreeNode *q) {
    if (!p && !q) return true;
    if (!p || !q) return false;
    return p->val == q->val && check(p->left, q->right) && check(p->right, q->left);
}

bool TreeNodeAlgorithm::isSymmetric(TreeNode *root) {
    return check(root, root);
};
